from django.db import models

# Create your models here.
from datetime import datetime

from django.db import models

# Create your models here.
class Category(models.Model):
    name = models.CharField(max_length=100,verbose_name='类别名称')
    createDate = models.DateTimeField(default=datetime.now(),verbose_name='创建时间')
    def __str__(self):
        return self.name
    class Meta:
        verbose_name_plural = '新闻分类'
        verbose_name = '新闻分类'
        db_table = 'news_category'

class News(models.Model):
    title=models.CharField(max_length=100,verbose_name='标题')
    content=models.TextField(verbose_name='内容')
    createDate = models.DateTimeField(default=datetime.now(),verbose_name='创建时间')
    category=models.ForeignKey(to=Category,related_name='news',on_delete=models.RESTRICT,verbose_name='新闻类别')
    def __str__(self):
        return self.title
    class Meta:
        verbose_name_plural = '新闻列表'
        verbose_name = '新闻列表'
        db_table = 'news_news'